<?
$id=$_GET["id"];
if (!$id)  {

header("location: sharinglist.php");
exit;
}

require("config.php");
require("header.php");
?>


<?
$showSharing = true;


if (!$id)  {

$table = "course_sharing";

$field = array(

"id",
"graduate",
"detail",
	"picture1",
	"picture2",
	"picture3",
	"schedule",
);

$exp = "AND status = 'Yes' and showcase='1' ORDER by order_index";

$r = unlimitQuery($table,$field,$exp);

//if (empty($r[0][0])) echo "wtf!";
$count = 0;
$list = array();
for ($i=0; $i<count($r); $i++) {

$table = "course_schedule";

$field = array(

"id",
"date",
"name",
);
//echo "name: " . $r[$i][6];

$exp = "and ccode='".$r[$i][0]."' ORDER by order_index Limit 1";

$r2 = unlimitQuery($table,$field,$exp);

if (!in_array($r2[0][0], $list)) {
	$list[$count]=$r2[0][0];
	$count++;

}

} 

}

else {


$table = "course_schedule";

$field = array(

"id",
"date",
"name",
);

$exp = "AND id = $id ";

$exp .= "ORDER by order_index Limit 1";

$r = unlimitQuery($table,$field,$exp);

$date = $r[0][1];
$name = $r[0][2];
$id=$r[0][0];

$schedule_id=$id;



$table = "course_sharing";

$field = array(

"id",
"graduate",
"detail",
	"picture1",
	"picture2",
	"picture3",
);

$exp = "and ccode='".$r[0][0]."' ORDER by order_index";

$r = unlimitQuery($table,$field,$exp);

}

?>










<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 

    <td width="186" valign="top"> 
      <?require("nav.php")?>
    </td>
    <td width="11"><img src="images/shim.gif" width="11" height="1"></td>
    <td valign="top"> 
      <?require("menu.php")?>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td align="right"><table width="100%" border="0">
              <tr> 
                <td height="50" class="header">&gt;&gt; Referencer</td>
              </tr>
            </table></td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">


        <tr> 
          <td align="right" colspan="2"><a href="sharinglist.php">Ls flere referencer</a></td>
        </tr>


<?php if ($id) { ?>
        <tr> 
          <td><b><?=$name?></b> </td><td align="Right" width="120"><a href="javascript:newWin('schedule_photo.php?id=<?=$schedule_id?>',770,500)">Se fotos</a></td>
        </tr>
        <tr> 
          <td colspan="2"> <?=outDate($date)?></td>
        </tr>
        <tr> 

          <td valign="top"> 

		  
<table>
		  <?for ($i=0;$i<count($r);$i++){?>


<tr><td valign="top">
		  <a href="<?=$PIC_DIR . "$table/" . $r[$i][3]?>" target="_blank"><?=showPic($PIC_DIR . "$table/" . $r[$i][3],"")?></a><br>
		  <a href="<?=$PIC_DIR . "$table/" . $r[$i][4]?>" target="_blank"><?=showPic($PIC_DIR . "$table/" . $r[$i][4],"")?></a><br>
		  <a href="<?=$PIC_DIR . "$table/" . $r[$i][5]?>" target="_blank"><?=showPic($PIC_DIR . "$table/" . $r[$i][5],"")?></a>
</td><td valign="top">


		  <p>
		  
		  
		  <u><?=$r[$i][1]?></u><br>
              <?=$r[$i][2]?></p>
</td></tr>
			<?}?>
</table>


			</td>
        </tr>
        <tr> 
          <td height="69" colspan="2"> <div align="right"><a href="print_course_sharing.php?id=<?=$id?>" target="_blank">Udskriv siden</a> | <a href="javascript:Redirect('email.php?id=<?=$id?>&p=graduate_sharing',3)">e-mail til en ven</a></div></td>
        </tr>
				
				
				<?php } else {
				
				for ($j=0;$j<count($list);$j++) {
				
				$table = "course_schedule";

$field = array(

"id",
"date",
"name",
);
//echo "id:" . $list[$j];
$exp = "AND id = '".$list[$j]."' ";

$exp .= " ORDER by order_index Limit 1";

$r = unlimitQuery($table,$field,$exp);

$date = $r[0][1];
$name = $r[0][2];
$id=$r[0][0];

$schedule_id=$id;
				$table = "course_sharing";

$field = array(

"id",
"graduate",
"detail",
	"picture1",
	"picture2",
	"picture3",
);

$exp = "and ccode='".$r[$i][0]."' ORDER by order_index Limit 1";

$r = unlimitQuery($table,$field,$exp);
				
				?>
				 <tr> 
          <td><b><?=$name?></b> </td><td align="Right" width="120"><a href="javascript:newWin('schedule_photo.php?id=<?=$schedule_id?>',770,500)">Se fotos</a></td>
        </tr>
        <tr> 
          <td colspan="2"> <?=outDate($date)?></td>
        </tr>
        <tr> 

          <td valign="top"> 

		  
<table>
		  <?for ($i=0;$i<count($r);$i++){?>


<tr><td valign="top">
		  <a href="<?=$PIC_DIR . "$table/" . $r[$i][3]?>" target="_blank"><?=showPic($PIC_DIR . "$table/" . $r[$i][3],"")?></a><br>
		  <a href="<?=$PIC_DIR . "$table/" . $r[$i][4]?>" target="_blank"><?=showPic($PIC_DIR . "$table/" . $r[$i][4],"")?></a><br>
		  <a href="<?=$PIC_DIR . "$table/" . $r[$i][5]?>" target="_blank"><?=showPic($PIC_DIR . "$table/" . $r[$i][5],"")?></a>
</td><td valign="top">


		  <p>
		  
		  
		  <u><?=$r[$i][1]?></u><br>
              <?=$r[$i][2]?></p>
</td></tr>
			<?}?>
</table>


			</td>
        </tr>
        <tr> 
          <td height="69" colspan="2"> <div align="right"><a href="print_course_sharing.php?id=<?=$id?>" target="_blank">Udskriv siden</a> | <a href="javascript:Redirect('email.php?id=<?=$id?>&p=graduate_sharing',3)">e-mail til en ven</a></div></td>
        </tr>
				
				
				
				
				
				
				<?php } } ?>
				
      </table>
      <br> <br> <br>
      <br> </td>
    <td width="11"><img src="images/shim.gif" width="11" height="1"></td>
    <td width="173" valign="top">
	
	
<?require("list.php")?>	 
	  
	  
    </td>

  </tr>
</table>





<?require("footer.php")?>	